<template>
  <!-- 专利 -->
  <el-descriptions :column="2" size="large">
    <el-descriptions-item label-class-name="right-align" label='成果来源'>
      <span class="text--info subtext" v-if='otherInfo.projectId'>项目</span>
      <span class="text--info subtext" v-else>非项目</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='成果名称'>
      <span class="text--info subtext">{{otherInfo.kyName}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='所属项目' v-if='otherInfo?.projectId'>
      <span class="text--info subtext">{{projectInfo?.projectName}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='项目编号' v-if='otherInfo?.projectId'>
      <span class="text--info subtext">{{projectInfo.projectCode}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='成果描述'>
      <span class="text--info subtext">{{otherInfo?.kyDesc}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='申报时间'>
      <span class="text--info subtext">{{otherInfo?.ext3}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='所属公司主体'>
      <span class="text--info subtext">{{otherInfo.companyEntityName}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='首次发表日期'>
      <span class="text--info subtext">{{otherInfo.firstPublishTime}}</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='申报单位'>
      <span class="text--info subtext" v-for="item in otherInfo.ext1List" :key="item.id">{{item.partakeUnitName}}&nbsp;&nbsp;</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='申报人'>
      <span class="text--info subtext" v-for="item in otherInfo.ext2List" :key="item.id">{{item.bizName}}&nbsp;&nbsp;</span>
    </el-descriptions-item>

    <el-descriptions-item label-class-name="right-align" label='上传文档'>
      <div v-if="otherInfo.kyAttachmentList?.length" class="file-wrap">
        <p
          class="text--info download-link subtext"
          v-for="(obj, index) in otherInfo?.kyAttachmentList"
          :key="index"
          @click.prevent="handlePreview(obj)"
        >
          <el-link :underline="false" icon="el-icon-folder">{{ obj?.fileName }}&nbsp;&nbsp;</el-link>
        </p>
      </div>
      <div class="text--info subtext file-wrap" v-else> - </div>
    </el-descriptions-item>
  </el-descriptions>
</template>

<script lang="ts" setup>
import {ref,watch} from "vue";
const props = defineProps({
  projectInfo: {
    type: Object,
    default:()=>{}
  },

  otherInfo:{
    type: Object,
    default:()=>{}
  }
});
const otherInfo = ref({})
const handlePreview = (item: any) => {
  if (item.response) {
    window.open(
      `${location.origin}${location.pathname}#/online?uuidFile=${item?.response.data.uuidFile}&fileName=${item?.response.data.fileName}`
    );
  } else {
    window.open(
      `${location.origin}${location.pathname}#/online?uuidFile=${item.uuidFile}&fileName=${item.fileName}`
    );
  }
};

watch(
  () => props.otherInfo,
  newvalue => {
    otherInfo.value = newvalue;
    otherInfo.value.kyAttachmentList = JSON.parse(otherInfo.value.kyAttachment);
    otherInfo.value.ext1List = JSON.parse(otherInfo.value.ext1);
    otherInfo.value.ext2List = JSON.parse(otherInfo.value.ext2);
  },
  { immediate: true }
);
</script>

<style lang="scss" scoped>
  .file-wrap{
    display: inline-block;
    vertical-align: top
  }
</style>
